package com.fpt.mockproject.j21.absd.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NaturalId;

@Entity
@Table(name = "COUNTRY")
@DynamicUpdate(value = true)
public class Country {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "CountryID", nullable = false, updatable = false, unique = true)
	private Long countryID;
	
	@NaturalId
	@Column(name = "CountryName", nullable = false, unique = true)
	private String countryName;
	
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "country")
	private Set<Address> addresses = new HashSet<>(0);
	
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "country")
	private Set<County> counties = new HashSet<>(0);
	
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "country")
	private Set<PostCode> postCodes = new HashSet<>(0);
	
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "country")
	private Set<Town> towns = new HashSet<>(0);
	
	public Set<Town> getTowns() {
		return towns;
	}
	public void setTowns(Set<Town> towns) {
		this.towns = towns;
	}
	public Set<Address> getAddresses() {
		return addresses;
	}
	public Set<County> getCounties() {
		return counties;
	}
	public void setCounties(Set<County> counties) {
		this.counties = counties;
	}
	public Set<PostCode> getPostCodes() {
		return postCodes;
	}
	public void setPostCodes(Set<PostCode> postCodes) {
		this.postCodes = postCodes;
	}
	public void setAddresses(Set<Address> addresses) {
		this.addresses = addresses;
	}
	public Long getCountryID() {
		return countryID;
	}
	public void setCountryID(Long countryID) {
		this.countryID = countryID;
	}
	public String getCountryName() {
		return countryName;
	}
	public void setCountryName(String countryName) {
		this.countryName = countryName;
	}
}
